package com.amado.course36ByteStream;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * ByteArrayInputStream 包含一个内部缓冲区，该缓冲区包含从流中读取的字节
 * 
 * @author Administrator
 *
 */
public class ByteArrayOutputStreamTest {
	public static void main(String[] args) {
		ByteArrayOutputStream out = new ByteArrayOutputStream(12);
		while (out.size() != 6) {
			try {
				out.write(System.in.read());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		byte[] byteArray = out.toByteArray();
		System.out.println(byteArray.length);
		System.out.println(new String(byteArray));
	}
}
